<template>
  <div v-loading="loading">
    <el-form ref="form" :model="form" :rules="rules" label-width="120px" class="dataForm">
      <el-row>
        <el-col :span="12">
          <el-form-item :label="$t('土地获取')" prop="landAcquire">
            <el-date-picker
              v-model="form.landAcquire"
              clearable
              style="width: 200px"
              type="month"
              :placeholder="$t('土地获取')"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('国有土地证')" prop="stateLand">
            <el-date-picker
              v-model="form.stateLand"
              clearable
              style="width: 200px"
              type="month"
              :placeholder="$t('国有土地证')"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('用地规划许可证')" prop="landAgree">
            <el-date-picker
              v-model="form.landAgree"
              clearable
              style="width: 200px"
              type="month"
              :placeholder="$t('用地规划许可证')"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('建设规划许可')" prop="constructionAgree">
            <el-date-picker
              v-model="form.constructionAgree"
              clearable
              style="width: 200px"
              type="month"
              :placeholder="$t('建设规划许可')"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('建设施工许可证')" prop="constructionBuildAgree">
            <el-date-picker
              v-model="form.constructionBuildAgree"
              clearable
              style="width: 200px"
              type="month"
              :placeholder="$t('建设施工许可证')"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('开发贷获取时间')" prop="developGain">
            <el-date-picker
              v-model="form.developGain"
              clearable
              style="width: 200px"
              type="month"
              :placeholder="$t('开发贷获取时间')"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('预售证时间')" prop="presellCard">
            <el-date-picker
              v-model="form.presellCard"
              clearable
              style="width: 200px"
              type="month"
              :placeholder="$t('预售证时间')"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('开票时间')" prop="ticket">
            <el-date-picker
              v-model="form.ticket"
              clearable
              style="width: 200px"
              type="month"
              :placeholder="$t('开票时间')"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('竣工验收时间')" prop="completed">
            <el-date-picker
              v-model="form.completed"
              clearable
              style="width: 200px"
              type="month"
              :placeholder="$t('竣工验收时间')"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('收回股东投入时间')" prop="takeBackShareholder">
            <el-date-picker
              v-model="form.takeBackShareholder"
              clearable
              style="width: 200px"
              type="month"
              :placeholder="$t('收回股东投入时间')"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('现金流回正时间')" prop="moneyFlow">
            <el-date-picker
              v-model="form.moneyFlow"
              clearable
              style="width: 200px"
              type="month"
              :placeholder="$t('现金流回正时间')"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer" style="text-align: right;">
      <!--保存 取消按钮-->
      <save-btn has-permi="system:planning" />
    </div>
  </div>
</template>

<script>
import { saveDealNodePlanning, getDealNodePlanning } from '@/api/deal/estate/nodePlan/dealNodePlanning'

    export default {
        data() {
            return {
                // 表单参数
                form: {
                  versionType: ''
                },
                // 遮罩层
                loading: false,
                // 表单校验
                rules: {
                }
            }
        },
        created() {
        },
        methods: {
            // 初始化数据
            init(id, type) {
                this.loading = true
                if (id != null && id !== undefined && id !== '') {
                    getDealNodePlanning(id).then(response => {
                        this.form = response.data
                        this.form.versionType = type
                        this.loading = false
                    })
                } else {
                    this.reset()
                    this.loading = false
                }
                 this.form.versionType = type
            },
            // 表单重置
            reset() {
                this.form = {
                    id: undefined,

                    landAcquire: undefined,

                    stateLand: undefined,

                    landAgree: undefined,

                    constructionAgree: undefined,

                    constructionBuildAgree: undefined,

                    developGain: undefined,

                    presellCard: undefined,

                    ticket: undefined,

                    completed: undefined,

                    takeBackShareholder: undefined,

                    moneyFlow: undefined,

                    createBy: undefined,

                    delFlag: undefined,

                    createTime: undefined,

                    remark: undefined

                }
                this.resetForm('form')
            },
            // 取消按钮
            cancel() {
                this.$parent.$parent.formOpen = false
                this.$parent.$parent.reset()
            },
            // 关闭form页面
            closeForm() {
                // 关闭form页面遮罩层
                this.loading = false
                // 关闭form页面
                if (this.$parent.$parent.formOpen !== undefined) {
                  this.$parent.$parent.formOpen = false
                }
                // 刷新list页面
                if (this.$parent.$parent.getList !== undefined) {
                  this.$parent.$parent.getList()
                }
            },
            /** 提交按钮 */
            submitForm: function() {
                this.$refs['form'].validate(valid => {
                    if (valid) {
                        this.loading = true
                        // 项目id
                         this.form.dealId = this.$route.query.id
                        saveDealNodePlanning(this.form).then(response => {
                            if (response.code === 200) {
                                this.msgSuccess(this.$t('保存成功'))
                                this.closeForm()
                            } else {
                                this.msgError(response.msg)
                            }
                            this.loading = false
                        })
                    } else {
                       this.locationError(document)
                    }
                })
           }

        }

    }
</script>
